package com.fitz.config;

import com.fitz.enums.SerializerEnum;
import com.fitz.proxy.ProxyFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 原先设计时服务提供方和消费方分开了
 * @author fitz 2020-5-18 19:00
 */

@Deprecated
@Configuration
public class RpcConsumerConfiguration {

    @Value("${fitz.rpc.consumer.max-pool-size}")
    private int maxPoolSize;

    @Value("${fitz.rpc.consumer.min-pool-size}")
    private int minPoolSize;

    @Value("${fitz.rpc.consumer.serializer-type}")
    private String serializerType = SerializerEnum.HESSIAN2.getType();

    @Bean
    public ProxyFactory init(){
        SerializerEnum serializer = null;
            serializer = SerializerEnum.find(serializerType);
            if (serializer == null){
                serializer = SerializerEnum.HESSIAN2;
            }
        return new ProxyFactory(minPoolSize,maxPoolSize, serializer.getCode());
    }
}
